"""
删除旧的邮件任务表
"""
from sqlalchemy import create_engine, text
from config import settings

def drop_old_email_tables():
    """删除旧的邮件任务表"""
    # 创建数据库引擎
    engine = create_engine(settings.database_url)
    
    with engine.begin() as conn:
        # 删除相关表
        try:
            # 先删除有外键约束的表
            conn.execute(text("DROP TABLE IF EXISTS email_logs"))
            conn.execute(text("DROP TABLE IF EXISTS email_tasks"))
            print("✅ 删除旧的邮件相关表成功")
        except Exception as e:
            print(f"删除表失败: {e}")

if __name__ == "__main__":
    drop_old_email_tables()
